<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
		<title>给你的，就不会再给别人！！</title>
	<link rel="shortcut icon" href="https://static.hdslb.com/images/favicon.ico">
	<link rel="stylesheet" href="css/demo03.css">
	<link rel="stylesheet" href="css/demo04.css">
</head>
<body>
	<div class="top">
		<div class="top-banner">
			<img src="https://s1.hdslb.com/bfs/static/passport/static/img/rl_top.35edfde.png" alt="">
		</div>	
	</div>
	<div class="WB_miniblog">
		<div class="content">
			<div class="left">
				<div id="btn1">首页</div>
				<div id="btn">我的</div>
				<div id="btn2">注销登录</div>
			</div>
			<div class="right">
				<div class="out">
					<div class="head">
						<p class="p1">来，说说你在做什么，想什么</p>
						<input type="text" id="name" placeholder="不添你是过不去的">
						<span id="parent"></span>
						<textarea name="content" id="content" cols="30" rows="10" placeholder="不添你肯定过不去"></textarea>
						<div style="text-align: right;">还能输入<span id="length">140</span>个字<input type="button" id="play" value="广播"></div>
					</div>
					<div class="text">
						<div class="in">大家在说</div>
					</div>

					<div class="abc">
					</div>
				</div>
	
			</div>
		</div>
		<button id="next" style="position: fixed;bottom: 0px;right: 0px;">下一页</button>
	</div>
	<script src="http://libs.baidu.com/jquery/1.11.1/jquery.js"></script>
	<script src="js/demo02.js"></script>
	<script>
		$(function() {
			 var myDate = new Date;
			 var mon = myDate.getMonth() + 1;
			 var date = myDate.getDate();
			 
		})
		var arr2 = [];
		var page = 1;
		var obj1;
		var obj;
		var  url = "http://39.105.222.9:8095/blog/query_blog/";
		function reload (page) {
			$.get(url,{},function(data) {
			if (data.result != 1) {
				alert("data.message");
			}else {
			    obj1 = data.datas;
				var star = 10 *(page - 1 );
				var end = star + 10;
				 obj = obj1.slice(star,end);
				for (var i =0;i< obj.length; i++) {
					var qDiv = $("<div class = 'q'></div>");
					$(".abc").append(qDiv);
					var q1Div = $("<div class = 'q1'></div>");
					q1Div.html("删除");
					qDiv.append(q1Div);
					var wDiv = $("<div class='w'num = '"+i+"'></div>")
					qDiv.append(wDiv);
					var img1 = $("<img src='"+obj[i].portrait+"'>");
					wDiv.append(img1);
					var eDiv = $("<div class='e'></div>");
					wDiv.append(eDiv);
					var rDiv = $("<div class='r'></div>");
					rDiv.html(obj[i].username)
					eDiv.append(rDiv);
					var span1 = $("<span class='t'></span>");
					var myDate = new Date;
			 		var mon = myDate.getMonth() + 1;
			 		var date = myDate.getDate();
					span1.html(mon+"月"+date+ "日");
					eDiv.append(span1);
					var span2 = $("<span class='y'></span>");
					var h1 = myDate.getHours();
					var min1 = myDate.getMinutes();
					span2.html(guolu(h1)+":"+guolu(min1));
					eDiv.append(span2);
					var iDiv = $("<div class='i'></div>");
					iDiv.html(obj[i].content);
					eDiv.append(iDiv);
					var q2Div = $("<div class='q2'></div>");
					qDiv.append(q2Div);
					var span3 = $("<span></span>")
					span3.html("收藏");
					q2Div.append(span3);
					var span4 = $("<span></span>")
					span4.html("转发");
					q2Div.append(span4);
					var span5 = $("<span></span>")
					span5.html("评论");
					q2Div.append(span5);
					var span6 = $("<span></span>")
					span6.html("点赞");
					q2Div.append(span6);
				}
				heihei();
			}
		})
			// body... 
		}
		function guolu(n) {
			if (n >= 10) {
				return n ;
			}else {
				return "0" + n;
				}
		}
		$("#btn").click(function() {
			location.href = "demo04.html";
		})
		$("#btn1").click(function() {
			location.href = "demo03.html";
		})
		$("#btn2").click(function(){
    		var siteurl = sessionStorage.token;
			var url ="http://39.105.222.9:8095/blog/logout_user/";
			var  pase  =  {"token":siteurl};
			$.post(url,pase,function(data) {
				if (data.result == 1) {
					sessionStorage.removeItem("token");

				}else {
					alert(data.message);
				}
				// body... 
			})
			
		})
	</script>
	<script>
		function heihei () {
			var rdiv = document.querySelectorAll(".r");
			console.log(rdiv);
			$(function() {
			$(".r").click(function(e) {
				var arr = Array.from(rdiv);
				var a = arr.indexOf(e.target);
				var  text = arr[a].innerHTML;
				console.log(text);
				var heihei   = sessionStorage.username;
				sessionStorage.setItem("linshi",heihei);
				sessionStorage.setItem("username",text);
				location.href = "demo05.html";
			
			})
				
		})

		}
		$("#next").click(function() {
			if (Math.floor(obj1.length / 10) > page) {
				page+=1;
		 	$(".abc").html("");
		 	reload(page);
			}else if (Math.floor(obj1.length / 10) == page ) {
				obj = obj1.length % 10;
				page+=1;
				reload(page);
			}else {
				page = 1;
				obj = 10;
				$(".abc").html("");
				reload(page);
				
			}
		})
		reload(1);
		
	</script>
</body>
</html>




















